//-----------------------
// SWDA_Window_SynthesisResult
//-----------------------
const _Swda_Window_Synthesis_Result_init = SWDA_Window_SynthesisResult.prototype.initialize;
SWDA_Window_SynthesisResult.prototype.initialize = function(x, y, width, height){
	this.clearSucessFlag();
	_Swda_Window_Synthesis_Result_init.call(this, x, y, width, height);
};

SWDA_Window_SynthesisResult.prototype.clearSucessFlag = function(){
	this._resultSuccess = false;
};

//合成结果
//这个函数只在执行真·合成时返回
//这个窗口绘制结果，对象用this._synthesisResult，与这个函数返回值无关
SWDA_Window_SynthesisResult.prototype.synthesisResult = function(){
	this._resultSuccess = this.meetsSynthesisResult();
	if(this._resultSuccess)
		return this.successfulSynthesisResult();
	else
		return this.failureResult(this._recipeItem1, this._recipeItem2);
};

//合成是否成功，必须在执行synthesisResult函数之后【即真合成之后】才有结果
SWDA_Window_SynthesisResult.prototype.isSuccessful = function(){
	return !!this._resultSuccess;
};

//成功产物
SWDA_Window_SynthesisResult.prototype.successfulSynthesisResult = function(){
	return this._synthesisResult;
};

//成功判定
SWDA_Window_SynthesisResult.prototype.meetsSynthesisResult = function(){
	return Math.random() < 0.8;
};

//失败产物
//receipe1和receipe2是可交换的，都是data对象
//这个默认返回值是插件参数中的默认产物
SWDA_Window_SynthesisResult.prototype.failureResult = function(receipe1, receipe2){
	return CP.SynthesisManager.DEFAULT_PRODUCE.object();
};

//-----------------------
// Scene_Synthesis
//-----------------------
//预览窗口确定响应
const _Swda_Scene_Synthesis_onResultOk = Scene_Synthesis.prototype.onResultOk;
Scene_Synthesis.prototype.onResultOk = function(){
	_Swda_Scene_Synthesis_onResultOk.call(this);
	this._resultWindow.clearSucessFlag();
};